import java.util.Arrays;

public class Leet1775 {

	public static void main(String[] args) {
		System.out.println(minOperations(new int[] {1,2,3,4,5,6}, new int[] {1,1,2,2,2,2}));
	}
	static public int minOperations(int[] nums1, int[] nums2) {
		int re = 0;
		int num1=0,num2=0;
		int[] nu1 = new int[6];
		int[] nu2 = new int[6];
		for(int t : nums1) {
			num1+=t;
			nu1[t-1]++;
		}
		for(int t : nums1) {
			num2+=t;
			nu2[t-1]++;
		}
		if(num1<num2) {
			int t = num2;
			num2 = num1;
			num1 = t;
			int[] te = nums2;
			nums2 = nums1;
			nums1 = te;
			te = nu1;
			nu1 = nu2;
			nu2 = te;
		}
		int[] nu = new int[6];
		for(int i = 0;i<6;i++) {
			nu[i]+=nu1[i]+nu2[5-i];
		}
		int num = num1-num2;
		int o = 5;
		while(num>5) {
			if(nu[o]!=0) {
				re++;
				num-=o;
				nu[o]--;
			}
			else
				o--;
		}
		return re;
    }

}
